<?php
/**
 * 
 *
 * PHP version 5.3.x
 *
 * @category 
 * @package  
 * @author   gouki <gouki.xiao@gmail.com>
 */

/**
 * SaeActiveRecord.php
 *
 * @category 
 * @package  
 * @author   gouki <gouki.xiao@gmail.com>
 * @version $Id$ 
 * @created 2011-11-23 11:51
 */ 
class SaeActiveRecord extends CActiveRecord{

    public function beforeFind(){
        $saeSetting = SaeCommon::getSaeConfig('db');
        $slavedb = isset($saeSetting['slave'])?$saeSetting['slave']:"db";
        return Yii::app()->getComponent($slavedb);
    }
    public function beforeSave(){
        $saeSetting = SaeCommon::getSaeConfig('db');
        $masterdb = isset($saeSetting['master'])?$saeSetting['master']:"db";
        return Yii::app()->getComponent($masterdb);
    }
}
